always @ (posedge clk) 
begin
	if (nrst = 0) begin
		hcount <= 0;
		hsync <= 1;
	end
	else
		if (hcount > 2611) and (hcount<2988) begin
			hsync <= 0;
		else
			hsync <= 1;
		end if
		if (hcount < 3177) begin
			hcount <= hcount + 1;
		else
			hcount <= 0;
		end if
	end if
end